package com.itheima.UDPdemo.UDP三种通信方式.广播;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;

public class SendMessageDemo {
    public static void main(String[] args) throws IOException
    {//广播和单播一样，只需要ip变为255.255.255.255即可

        DatagramSocket ds=new DatagramSocket();

        String string="范钦昱是帅哥";
        byte[] bytes=string.getBytes();
        InetAddress inetAddress=InetAddress.getByName("255.255.255.255");
        int port=10086;
        DatagramPacket dp=new DatagramPacket(bytes,bytes.length,inetAddress,port);

        ds.send(dp);
        ds.close();

    }
}
